package com.qys.training.server.controller;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.qys.training.base.dto.BaseResult;
import com.qys.training.biz.auth.service.HazelcastService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/openapi")
public class OpenapiController {
    public static final Logger logger = LoggerFactory.getLogger(OpenapiController.class);
    @Resource
    private HazelcastInstance hazelcastInstance;

    @GetMapping("/listener")
    public BaseResult listener() {
        IMap<Object, Object> listener = hazelcastInstance.getMap("listener");
        Object obj = listener.get("listener");
        if (obj != null) {
            String status = obj.toString();
            if ("1".equals(status)) {
                return BaseResult.success("openapi服务已启动");
            }
        }
        return BaseResult.success("openapi服务未启动");
    }
}
